{layout name="layout" /}

<div class="Hui-article">
    <article class="cl pd-20" style="min-width: 1200px; max-width: 80%;">
        <div class="cl pd-5 bg-1 bk-gray mt-20">
            <span class="l">
                <a href="javascript:;" onclick="del_all()" class="btn btn-danger radius">
                    <i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
                <a href="/admin_user/add.html" class="btn btn-primary radius">
                    <i class="Hui-iconfont">&#xe600;</i> 添加管理员</a>
            </span>
        </div>
        <table class="table table-border table-bordered table-bg">
            <thead>
                <tr>
                    <th scope="col" colspan="11">员工列表</th>
                </tr>
                <tr class="text-c">
                    <th width="25">
                        <input type="checkbox" name="allcheck" value="">
                    </th>
                    <th width="40px">ID</th>
                    <th width="100px">登录名</th>
                    <th width="100px">组别</th>
                    <th width="100px">笔名</th>
                    <th width="160px">邮箱</th>
                    <th width="100px">添加时间</th>
                    <th width="120px">最近登陆时间</th>
                    <th width="120px">最近登陆IP</th>
                    <th width="80px">状态</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {foreach $data as $val}
                <tr class="text-c">
                    <td>
                        <input type="checkbox" value="{$val.id}" name="checkbox[]">
                    </td>
                    <td>{$val.id}</td>
                    <td>{$val.username}</td>
                    <td>{$val.role_id|model('adminrole')->getRoleName}</td>
                    <td>{$val.pen_name}</td>
                    <td>{$val.email}</td>
                    <td>{$val.ctime|date='Y-m-d', ###}</td>
                    {notempty name="val.login_time"}
                    <td>{$val.login_time|date='Y-m-d H:i:s', ###}</td>
                    <td>{$val.login_ip|inet_ntoa}</td>
                    {else/}
                    <td>无记录</td>
                    <td></td>
                    {/notempty}
                    <td class="td-status">{eq name="val.status" value="1"}
                        <a href="javascript:void(0);" title="停用" onClick="status('stop',this,'{$val.id}')" style="text-decoration:none">
                            <span class="label label-success radius">启用</span>
                        </a>
                        {else/}
                        <a href="javascript:void(0);" title="启用" onClick="status('start',this,'{$val.id}')" style="text-decoration:none">
                            <span class="label label-danger radius">停用</span>
                        </a>{/eq}</td>
                    <td class="td-manage">
                        {eq name='Think.session.uid' value="1"}
                        <a href="javascript:void(0);" title="重置密码" style="text-decoration:none" class="ml-10" onclick="reset_pwd(this, '{$val.id}')">
                            <i class="Hui-iconfont">&#xe63f;</i>
                        </a>
                        {/eq} {neq name="val.id" value="1"}
                        <a title="编辑" href="{:url('/admin_user/edit','id='.$val.id)}" class="ml-5" style="text-decoration:none">
                            <i class="Hui-iconfont">&#xe6df;</i>
                        </a>
                        <a title="删除" href="javascript:;" onclick="del(this,'{$val.id}')" class="ml-5" style="text-decoration:none">
                            <i class="Hui-iconfont">&#xe6e2;</i>
                        </a>
                        {/neq}
                    </td>
                </tr>
                {/foreach}
            </tbody>
        </table>
    </article>
</div>

<script type="text/javascript">
    function reset_pwd(obj, id) {
        $.post('modifypwd', {
            'id': id
        }, function (data) {
            if (data.code == 2) {
                if (id == 1) {
                    layer.msg(data.msg + ", 请重新登录", {
                        icon: 6,
                        time: 1000
                    });
                    setTimeout("window.location.href = '/login/logout';", 2000);
                } else {
                    layer.msg(data.msg, {
                        icon: 6,
                        time: 1000
                    });
                }
            } else {
                layer.msg(data.msg, {
                    icon: 5,
                    time: 1000
                });

                return false;
            }
        }, 'json');
    }
</script>